<%@ page import="com.wuchao.service.serviceimpl.ServiceImpl" %>
<%@ page import="com.wuchao.entity.Page" %>
<%@ page import="com.wuchao.entity.Pojo" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: 吴超
  Date: 2022/4/20
  Time: 14:50
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <style>
        table{
            width: 600px;
            margin: auto;
        }
    </style>
</head>
<body>
    <h1>欢迎来到分页页面</h1>
<table border="3">
    <tr>
        <th>id</th>
        <th>name</th>
    </tr>
    <% ServiceImpl sl = new ServiceImpl();
        Page page1 = new Page();
    page1.setPageNum(3);
        page1.setCurrentPage(1);
      page1.setSum(sl.isLoading("select count(1) from t143"));
        page1.setTotalPage(page1.getSum()%3==0?page1.getSum()/3:page1.getSum()/3+1);
        if(request.getParameter("currentPage")!=null){
            page1.setCurrentPage( Integer.parseInt(request.getParameter("currentPage")));
        }
        List<Pojo> poJo = sl.findPoJo("select * from t143 limit ?,?",
                ( page1.getCurrentPage()-1)*page1.getPageNum(),page1.getPageNum());
        for(Pojo xjj : poJo){


        %>
   <tr>
        <td><%=xjj.getId()%></td>
        <td><%=xjj.getName()%></td>
    </tr>
    <% }%>
</table>
<a href="${pageContext.request.contextPath}/ServletPage?num=<%=page1.getCurrentPage()+1%>">+</a>
</body>
</html>
